<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/common/taglibs.jsp" %>
<div class="main-content">
    <div class="main-content-inner">
        <div class="breadcrumbs" id="breadcrumbs">
            <div class="col-md-8 col-xs-12">
                <%@include file="/WEB-INF/common/back/breadcrumb.jsp" %>
            </div>
        </div>

        <div class="page-content">
            <div class="row">
                <div class="col-xs-12 col-sm-6 widget-container-col ui-sortable">
                    <div class="widget-box ui-sortable-handle widget-color-blue">
                        <div class="widget-header">
                            <h5 class="widget-title">发布参数设置</h5>

                            <div class="widget-toolbar">
                                <a href="#" data-action="collapse">
                                    <i class="ace-icon fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>

                        <div class="widget-body">
                            <div class="widget-main no-padding">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead class="thin-border-bottom">
                                    <tr>
                                        <th>参数</th>
                                        <th>最小空间MB</th>
                                        <th>最大空间MB</th>
                                        <th>最小个数</th>
                                        <th>最大个数</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    <tr>
                                        <td>图片</td>
                                        <td>
                                            <a id="pic_min_space" class="parameter" href="javascript:void(0)">${config.pic_min_space==null? "*":config.pic_min_space.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="pic_max_space" class="parameter" href="javascript:void(0)">${config.pic_max_space.configValue==null? "*":config.pic_max_space.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="pic_min_count" class="parameter" href="javascript:void(0)">${config.pic_min_count.configValue==null? "*":config.pic_min_count.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="pic_max_count" class="parameter" href="javascript:void(0)">${config.pic_max_count.configValue==null? "*":config.pic_max_count.configValue}</a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>视频</td>
                                        <td>
                                            <a id="video_min_space" class="parameter" href="javascript:void(0)">${config.video_min_space.configValue==null? "*":config.video_min_space.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="video_max_space" class="parameter" href="javascript:void(0)">${config.video_max_space.configValue==null? "*":config.video_max_space.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="video_min_count" class="parameter" href="javascript:void(0)">${config.video_min_count.configValue==null? "*":config.video_min_count.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="video_max_count" class="parameter" href="javascript:void(0)">${config.video_max_count.configValue==null? "*":config.video_max_count.configValue}</a>
                                        </td>
                                    </tr>

                                    <tr>
                                        <td>文档</td>
                                        <td>
                                            <a id="doc_min_space" class="parameter" href="javascript:void(0)">${config.doc_min_space.configValue==null? "*":config.doc_min_space.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="doc_max_space" class="parameter" href="javascript:void(0)">${config.doc_max_space.configValue==null? "*":config.doc_max_space.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="doc_min_count" class="parameter" href="javascript:void(0)">${config.doc_min_count.configValue==null? "*":config.doc_min_count.configValue}</a>
                                        </td>
                                        <td>
                                            <a id="doc_max_count" class="parameter" href="javascript:void(0)">${config.doc_max_count.configValue==null? "*":config.doc_max_count.configValue}</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12 col-sm-6 widget-container-col ui-sortable">
                    <div class="widget-box ui-sortable-handle widget-color-blue">
                        <div class="widget-header">
                            <h5 class="widget-title">批量导出设置</h5>

                            <div class="widget-toolbar">
                                <a href="#" data-action="collapse">
                                    <i class="ace-icon fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>

                        <div class="widget-body">
                            <div class="widget-main no-padding">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead class="thin-border-bottom">
                                    <tr>
                                        <th>参数名</th>
                                        <th>参数值</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    <tr>
                                        <td class="">一次最多</td>

                                        <td>
                                            <a id="export_max_once" class="parameter" href="javascript:void(0)">${config.export_max_once.configValue==null? "*":config.export_max_once.configValue}</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12 col-sm-6 widget-container-col ui-sortable">
                    <div class="widget-box ui-sortable-handle widget-color-blue">
                        <div class="widget-header">
                            <h5 class="widget-title">完善度设置</h5>

                            <div class="widget-toolbar">
                                <a href="#" data-action="collapse">
                                    <i class="ace-icon fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>

                        <div class="widget-body">
                            <div class="widget-main no-padding">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead class="thin-border-bottom">
                                    <tr>
                                        <th>参数</th>
                                        <th>图片个数1-3</th>
                                        <th>图片个数3-5</th>
                                        <th>内容字数1~80</th>
                                        <th>内容字数80+</th>
                                        <th>用量字数1~40</th>
                                        <th>用量字数40+</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    <tr>
                                        <td class="">权重百分比</td>

                                        <td><a id="finish_pic_4less" class="parameter" href="javascript:void(0)">${config.finish_pic_4less.configValue==null? "*":config.finish_pic_4less.configValue}</a></td>
                                        <td><a id="finish_pic_4more" class="parameter" href="javascript:void(0)">${config.finish_pic_4more.configValue==null? "*":config.finish_pic_4more.configValue}</a></td>
                                        <td><a id="finish_content_80less" class="parameter" href="javascript:void(0)">${config.finish_content_80less.configValue==null? "*":config.finish_content_80less.configValue}</a></td>
                                        <td><a id="finish_content_80more" class="parameter" href="javascript:void(0)">${config.finish_content_80more.configValue==null? "*":config.finish_content_80more.configValue}</a></td>
                                        <td><a id="finish_word_40less" class="parameter" href="javascript:void(0)">${config.finish_word_40less.configValue==null? "*":config.finish_word_40less.configValue}</a></td>
                                        <td><a id="finish_word_40more" class="parameter" href="javascript:void(0)">${config.finish_word_40more.configValue==null? "*":config.finish_word_40more.configValue}</a></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12 col-sm-6 widget-container-col ui-sortable">
                    <div class="widget-box ui-sortable-handle widget-color-blue">
                        <div class="widget-header">
                            <h5 class="widget-title">匹配度设置</h5>

                            <div class="widget-toolbar">
                                <a href="#" data-action="collapse">
                                    <i class="ace-icon fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>

                        <div class="widget-body">
                            <div class="widget-main no-padding">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead class="thin-border-bottom">
                                    <tr>
                                        <th>参数</th>
                                        <th>标题相同</th>
                                        <th>所属分类相同</th>
                                        <th>所属产品相同</th>
                                        <th>内容长度差距小于5%</th>
                                        <th>用法用量内容长度差距小于5%</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    <tr>
                                        <td class="">权重百分比</td>

                                        <td><a id="match_titile" class="parameter" href="javascript:void(0)">${config.match_titile.configValue==null? "*":config.match_titile.configValue}</a></td>
                                        <td><a id="match_category" class="parameter" href="javascript:void(0)">${config.match_category.configValue==null? "*":config.match_category.configValue}</a></td>
                                        <td><a id="match_product" class="parameter" href="javascript:void(0)">${config.match_product.configValue==null? "*":config.match_product.configValue}</a></td>
                                        <td><a id="match_content" class="parameter" href="javascript:void(0)">${config.match_content.configValue==null? "*":config.match_content.configValue}</a></td>
                                        <td><a id="match_dosage" class="parameter" href="javascript:void(0)">${config.match_dosage.configValue==null? "*":config.match_dosage.configValue}</a></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="modal-parameter" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog">
        <form id="parameterForm" method="post" class="form-horizontal">
            <input type="hidden" id="registerName">
            <div class="modal-content">
                <div class="modal-header no-padding">
                    <div class="table-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            <span class="white">&times;</span>
                        </button>
                        参数修改
                    </div>
                </div>
                <div class="modal-body" style="max-height: 500px;overflow-y: scroll;">
                    <div id="modal-tip" class="red clearfix"></div>
                    <div class="form-group">
                        <label id="parameterName" class="blue col-sm-3 control-label no-padding-right"> 参数 </label>

                        <div class="col-sm-9">
                            <input id="parameterValue" type="text" name="parameterValue" class="col-xs-10 col-sm-5">
                        </div>
                    </div>
                </div>
                <div class="modal-footer no-margin-top">
                    <div class="text-center">
                        <button id="submitPrameterButton" type="button" class="btn btn-app btn-success btn-xs">
                            <i class="ace-icon fa fa-floppy-o bigger-160"></i>保存
                        </button>
                        <button class="btn btn-app btn-pink btn-xs" data-dismiss="modal">
                            <i class="ace-icon fa fa-share bigger-160"></i>取消
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    var jqLoadingOption = {
        backgroudColor: "#FFFFFF",//背景色
        backgroundImage: "/static/assets/css/images/loading.gif",//背景图片
        text: "正在处理中，请耐心等待....",//文字
        width: 250,//宽度
        height: 60,//高度
        type: 0 //0全部遮，1 局部遮
    };
    $(document).ready(function () {
        $(".parameter").bind("click", function () {
            var register = this.id;
            $("#registerName").val(register);
            $("#parameterForm")[0].reset();
            $("#parameterName").html($("#" + register + "Label").html());
            $("#parameterValue").val($("#" + register).html());
            $("#modal-parameter").modal("show");
        });

        $("#submitPrameterButton").on("click", function (e) {
            var value = $("input[name='parameterValue']").val();
            var register = $("#registerName").val();

            $("#submitPrameterButton").attr("disabled", "disabled");
            $.fn.jqLoading(jqLoadingOption);
            $.ajax({
                type: "POST",
                dataType: 'json',
                url: '${contextPath}/sys/config/saveParam',
                data: {configKey: register, configValue: $("#parameterValue").val()},
                success: function (data) {
                    $.fn.jqLoading.hide();
                    if (data.success) {
                        $("#modal-parameter").modal("hide");
                        $("#" + register).html($("#parameterValue").val());
                    }
                    else {
                        layer.msg(data.msg);
                    }
                    $("#submitPrameterButton").removeAttr("disabled");
                },
                error: function (data, status, e) {
                    $("#submitPrameterButton").removeAttr("disabled");
                    $.fn.jqLoading.hide();
                }
            });
        });
    });
</script>
